Skip to content

DB and HTTP semantic convention stability migration for Redis instrumentation#4370

Open
tammy-baylis-swi wants to merge 9 commits intoopen-telemetry:mainfrom
tammy-baylis-swi:redis-semconv-opt-in
Open

DB and HTTP semantic convention stability migration for Redis instrumentation#4370
tammy-baylis-swi wants to merge 9 commits intoopen-telemetry:mainfrom
tammy-baylis-swi:redis-semconv-opt-in

Conversation

@tammy-baylis-swi
Copy link
Copy Markdown
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Mar 27, 2026

Description

Add Redis instrumentor support for when OTEL_SEMCONV_STABILITY_OPT_IN includes

  • "database" or "database/dup"
  • "http" or "http/dup"

EDIT: This uses now-merged updates from SQLAlchemy PR, no conflicts 🙂 This duplicates all _semconv helper updates in #4110 at 02adc40

Fixes #2930, #2885

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Added unit tests

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

pluggy==1.6.0
py-cpuinfo==9.0.0
pytest==7.4.4
pytest-asyncio==0.23.5
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 1c7e3cc so Python 3.9 tests pass, else RuntimeError: There is no current event loop in thread 'MainThread'.

Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - thanks @tammy-baylis-swi.

Left some queries about some semconv keys and a couple of suggestions.

)

db = conn_kwargs.get("db", 0)
attributes[DB_REDIS_DATABASE_INDEX] = db
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think db.redis.database_index became db.namespace - do we have a set helper that can use old/new/dual write for these?

_set_http_net_peer_name_client(
attributes, conn_kwargs.get("path", ""), http_sem_conv_opt_in_mode
)
attributes[NET_TRANSPORT] = NetTransportValues.OTHER.value
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think net.transport has been deprecated - should we drop this in stable mode?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. maybe just set if _report_old()

conn_kwargs.get("port", 6379),
http_sem_conv_opt_in_mode,
)
attributes[NET_TRANSPORT] = NetTransportValues.IP_TCP.value
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

self.assertEqual(span.status.status_code, trace.StatusCode.UNSET)


class TestRedisSemconvConfiguration(TestRedis):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to inherit TestRedis or could we use TestBase? I think we'll re-run all the stuff in TestRedis like this.

I think we're missing the async tests for _async_traced_execute_factory and _async_traced_execute_pipeline_factory too.

response_hook: ResponseHook | None = None,
):
# Get semconv opt-in modes for database and HTTP signal types
_OpenTelemetrySemanticConventionStability._initialize()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are duplicated across all four factories, should we add a helper?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

opentelemetry-instrumentation-redis: semantic convention stability migration

3 participants